package com.example.springAop.com.demo.cglibDynamicProxy;

import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

public class AccountAdvice implements MethodInterceptor {

    /**
     * 代理方法，每次调用目标方法时都会进到这里
     * @param o
     * @param method
     * @param objects
     * @param methodProxy
     * @return
     * @throws Throwable
     */
    @Override
    public Object intercept(Object o, Method method,
                            Object[] args, MethodProxy methodProxy) throws Throwable {
        before();
        return methodProxy.invokeSuper(o, args);
    }

    /**
     * 前置增强
     */
    private void before(){
        System.out.println("对转账人身份进行验证");
    }

}
